url = '/:slug|viewlogistics-\d+.html$'
description = '订单发送邮件'
is_hidden = 0
layout = 'default'
[session]
security = "user"
redirect = "account/login"
==
use Jason\Ccshop\Controllers\Orders;
function onStart() {
    header("Content-type: text/html; charset=utf-8");
    $userid_login = $this['user']['attributes']['id'];
    $slugArr = explode('-', str_replace('.html', '', $this->param('slug')));
    $sn = $slugArr['1'];
    $o = (new Orders());
    $order = $o->orderDetail($sn);
    $userid_order = $order['attributes']['uid'];
    if($order == null){
        return redirect('/account/login.html');
    }
    if($userid_order != $userid_login){
        return redirect('/account/login.html');
    }

    if(isset($order->custom_fields['bill_no']) && $order->custom_fields['bill_no']){
        $result = $o->viewLogistics($order->custom_fields['bill_no']);
    }else{
        $result = trans('jason.ccshop::lang.userorder.no_logistics_information');
    }
    $this['has_logistics'] = is_array($result) ? 1 : 0;
    $this['bill_no'] = isset($order->custom_fields['bill_no']) ? $order->custom_fields['bill_no'] : '' ;
    $this['result'] = $result;
    $this['order'] = $order;
}
==
<div class="content">
    <div class="title-return">
        <h2>オーダー追跡</h2>
        <a href="javascript:;" onclick="history.go(-1);return false;"><img src="{{ 'assets/img/btn_back.gif'|theme}}" alt="戻る"></a>
        <!-- <a href="javascript:;" onclick="window.location.reload()" class="icon-refresh">
            <i class="fa fa-refresh"></i>
        </a> -->
        <a href="/sendorderemail-{{ order.sn }}.html" class="icon-email2">
            <i class="fa fa-envelope"></i>
        </a>
    </div>
   
    {% if bill_no %}
    <div class="bill_no clear">
        <p>運送会社：
            <b>
                {% if bill_no|trim|slice(0,2) in [16]%}
                YDH
                {% elseif starts_with( bill_no|trim , 'LX')%}
                邮政小包
                {% elseif starts_with( bill_no|trim , 'EA')%}
                EMS国際郵便配送
                {% elseif bill_no|trim|slice(0,1) in [1,2,3,4,5,7,8,9] and bill_no|trim|slice(0,2) not in [16] %}
                DHL
                {% endif %}
            </b>
        </p>
        <p>追跡番号：<b>{{ bill_no }}</b></p>
    </div>
    {% endif %}
    
    <div class="bill_cont">
        {% if has_logistics %}
            {% for info in result %}
            <div class="bill_content">
                <p> {% if info.track_location %}【{{ info.track_location | raw }}】{% endif %}{{ info.track_description_en | raw }}</p>
                <p>{{ info.track_occur_date }}</p>
            </div>
            {% endfor %}
        {% else %}
            {{ result }}
        {% endif %}
    </div>

</div>